package com.base.web.socket.controller.api;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.base.common.redis.RedisUtils;
import com.base.common.utils.R;
import com.base.web.socket.utils.ChatMsgUtils;

@RestController
@RequestMapping("/api/chat")
public class ChatApiController {

	@Resource
	private RedisUtils redis;

	@GetMapping("/getMsgs")
	public R getMsgs(String userId, String friendId) {
		String key = ChatMsgUtils.getKey(userId, friendId);

		List<Object> list = redis.getList(key, 0, -1);
		return R.ok().put("list", list);
	}
}
